import java.util.HashMap;
import java.util.Map;

class User{
    private String name;
    private String phone;

    public User(String name, String phone) {
        this.name = name;
        this.phone = phone;
    }

    public String getName() {
        return name;
    }

    public String getPhone() {
        return phone;
    }
}
interface Website{
    public abstract void Use(User user);
}
class ConcreteWebsite implements Website{
    private String type;

    public ConcreteWebsite(String type) {
        this.type = type;
    }

    @Override
    public void Use(User user) {
        System.out.println("商家："+user.getName()+"电话："+user.getPhone()+"网站类型："+this.type);
    }
}
class WebsiteFactory{
    private Map<String,Website> map=new HashMap<>();
    public Website GetWebsite(String key){
        Website o=map.get(key);
        if (o==null){
            map.put(key,new ConcreteWebsite(key));
            o= map.get(key);
        }
        return o;
    }
    public int GetWebsiteCount(){
        return map.size();
    }
}
public class Test {
    public static void main(String[] args) {
        WebsiteFactory f=new WebsiteFactory();
        User u1=new User("贵州大学","123456");
//        获取唯一的产品展示类型的享元对象
        Website w1=f.GetWebsite("产品展示");
        w1.Use(u1);

        User u2=new User("比特培训","123456");
//        获取唯一的产品展示类型的享元对象
        Website w2=f.GetWebsite("产品展示");
        w2.Use(u2);

        User u3=new User("软件工程","123456");
//        获取唯一的产品展示类型的享元对象
        Website w3=f.GetWebsite("产品展示");
        w3.Use(u3);

        System.out.println("网站的对象的个数为"+f.GetWebsiteCount());
    }
}
